﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartProduction.Domain;
using SmartProduction.ErrorCode;
using SmartProduction.Read.API.Application.Commands.JobCommand;
using SmartProduction.Read.API.Application.Commands.ManifestCommand;
using SmartProduction.Read.API.Application.Commands.STaskCommand__生产管理;
using SmartProduction.Read.API.Dto;

namespace SmartProduction.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public JobController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 工作中心列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<APIPaing<Job>>> JobGet([FromQuery]JobQueryCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 生产任务列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<APIPaing<STask>>> STaskGet([FromQuery] STaskGetCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 库存清单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Manifest>>> Handle([FromQuery]ManifestGetCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
